package th.go.drr.gps.domain;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Id;
import javax.persistence.TableGenerator;

@Entity
@Table(name="authorities")
public class Authority implements Serializable {
	
	private static final long serialVersionUID = -9041039841537929538L;

	@GeneratedValue(generator = "AUTHORITY_SEQ", strategy = GenerationType.TABLE)
	@Id
	@TableGenerator(name = "AUTHORITY_SEQ",pkColumnValue = "1",table="sequence",	allocationSize=1 )
	private Long id;

	@Column( name="authority",length=31,updatable = false,nullable = false)
	private String authority; 
	
		

	public String getAuthority() {
		return this.authority;
	}

	public void setAuthority(String authority) {
		this.authority = authority;
	}

	
	@ManyToOne(optional = false)
//	@JoinColumn(name = "id",insertable=false,updatable =false")
	
	@JoinTable(name = "usr_authorities", joinColumns = {
		@JoinColumn(name="authorities_id",referencedColumnName="id")
		},
		inverseJoinColumns = {
		@JoinColumn(name="usr_id",referencedColumnName="id")
		}
	)
	private Usr usr;
	public Usr getUsr() {
		return usr;
	}

	public void setUsr(Usr usr) {
		this.usr = usr;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}
	
}